package cn.example.demo.modules.house.dict;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * <p>
 * 活动状态
 * </p>
 *
 * @author Lizuxian
 * @create 2022/2/27 0:55
 */
@Getter
@AllArgsConstructor
public enum AppraiseScore {
    LEVEL1("1", "差评"),
    LEVEL2("2", "一般般"),
    LEVEL3("3", "不错"),
    LEVEL4("4", "满意"),
    LEVEL5("5", "非常满意");

    private final String code;
    private final String name;

    /**
     * 根据code获取枚举
     */
    public static AppraiseScore codeToEnum(String code) {
        if (null != code) {
            for (AppraiseScore e : AppraiseScore.values()) {
                if (e.getCode().equals(code)) {
                    return e;
                }
            }
        }
        return null;
    }

    /**
     * 编码转化成中文含义
     *
     * @author liuhanqing
     * @date 2021/1/15 13:36
     */
    public static String codeToName(String code) {
        if (null != code) {
            for (AppraiseScore e : AppraiseScore.values()) {
                if (e.getCode().equals(code)) {
                    return e.getName();
                }
            }
        }
        return "未知";
    }
}
